import { reactive, nextTick } from 'vue'
import { dialogVisible, dialogForm, setDialogForm, disabled } from './dialog.js'
import { JSONCopy } from '@components/js/utile.js'

export function tabSelectionChange(val) {
  console.log(val)
}
export function click(page, size) {
  console.log(page, size)
}
export function deleteRow(index, rows) {
  rows.splice(index, 1)
}
export let tableData = reactive([])
export function createRow() {
  dialogVisible.value = true
  disabled.value = false
  nextTick(function () {
    dialogForm.value.resetFields()
  })
}
export function addRow(data) {
  tableData.push(JSONCopy(data))
}
export function detaileRow(data) {
  dialogVisible.value = true
  disabled.value = true
  // 在表单没有显示前赋值，会被表单认作默认值。猜测
  nextTick(function () {
    setDialogForm(data)
  })
}
